<?php
class Page{

	private $page_id;
	private $page_title;
	private $page_contents = array();
	
	public function __construct($id){
		$link = getConnection();
		$query= sprintf("SELECT pa.page_title, pl.place_zone, co.content_title, co.content_id 
		FROM ee_page pa 
			INNER JOIN ee_content_page_place cpp ON pa.page_id = cpp.page_id 
			INNER JOIN ee_content co ON cpp.content_id = co.content_id 
			INNER JOIN ee_place pl ON cpp.place_id = pl.place_id
		WHERE pa.page_id = '%s'", mysql_real_escape_string($id));
		$res = mysql_query($query, $link);
		$a = true;
		while($row = mysql_fetch_assoc($res)){
			if($a){
				$this->page_title = $row['page_title'];
				$this->page_id = $id;
				$a = false;
			}
			$co = array( "id" => $row['content_id'], "title" => $row['content_title']);
			$this->page_contents[$row['place_zone']] = $co;
		}
	}
	
	public function getTitle(){
		return $this->page_title;
	}
	public function getId(){
		return $this->page_id;
	}
	public function getContents(){
		return $this->page_contents;
	}
}
?>